#include <iostream>

class Car
{
public:
    virtual void create() = 0;
};

class BENZ:public Car
{
public:
    void create()
    {
        std::cout<<"创建一辆奔驰"<<std::endl;
    }
};

class BMW:public Car
{
public:
    void create()
    {
        std::cout<<"创建一辆宝马"<<std::endl;
    }
};

class BYD:public Car
{
public:
    void create()
    {
        std::cout<<"创建一辆比亚迪"<<std::endl;
    }
};

//工厂类：生产对象  将对象指针和构建对象的过程解耦
class Factory
{
public:
    Car* CreateBenz()
    {
        return new BENZ();
    }
    Car* CreateBMW()
    {
        return new BMW();
    }
};

int main()
{
    Factory f;
    Car *c = f.CreateBenz();
    Car *m = f.CreateBMW();
    c->create();
    m->create();
}